import { BookItem, BookMarkItem, ChapterItem, ParagraphItem, ReadChapterItem } from '../types/book'
import { http } from '@/utils/http'


/**
 *
 * @param currentChapterId  当前章节id
 * @param bookId 书籍id
 * @returns 当前章节内容
 */

export const listParagraphItemAPI = (
	currentChapterId : number
) => {
	return http<ParagraphItem[]>({
		url: '/fanqie/paragraphs/listParagraphItem',
		method: 'GET',
		data: {
			chapterId: currentChapterId,
		}
	})
}
/**
 *
 * @param currentBookId  书籍id
 * @returns 章节列表
 */
export const listChapterItemAPI = (currentBookId : number) => {
	return http<ChapterItem[]>({
		url: '/fanqie/chapters/listChapterItem',
		method: 'GET',
		data: {
			bookId: currentBookId,
		}
	})
}

/**
 *查询阅读章节历史
 * @param currentBookId  书籍id
 * @returns 章节列表
 */
export const getReadChapterItemAPI = (currentBookId : number) => {
	return http<ReadChapterItem>({
		url: '/fanqie/userBookReadHistory/getReadChapterItem',
		method: 'GET',
		data: {
			bookId: currentBookId,
		}
	})
}
/**
 *新增阅读章节历史
 * @param currentBookId  书籍id
 * @param chapterIndex
 * @returns 章节列表
 */
export const addReadChapterItemAPI = (bookId : number, chapterIndex : number) => {
	return http<ReadChapterItem>({
		url: '/fanqie/userBookReadHistory/addReadChapterItem',
		method: 'GET',
		data: {
			bookId,
			chapterIndex
		}
	})
}




/**
 * 根据书籍id查询书本信息
 * @param bookId 书籍id
 * @returns 书籍信息
 */
export const getBookInfoByIdAPI = (bookId : number) => {
	return http<BookItem>({
		url: '/fanqie/books/getBookInfoById',
		method: 'GET',
		data: {
			bookId: bookId
		}
	})
}